import java.io.IOException;
import java.net.*;

/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2021-12-24
 * Time:21:06
 */
public class Server implements Runnable{
    int port;
    InetAddress address;
    byte[] data = new byte[1024];

    public Server(InetAddress address, byte[] data,int port) {
        this.address = address;
        this.data = data;
        this.port = port;
    }

    @Override
    public void run() {

        try {
            DatagramPacket dataPack = new DatagramPacket(data,data.length,address,port);
            DatagramSocket send = new DatagramSocket();
            send.send(dataPack);
            send.close();
        } catch (SocketException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
